package com.wc.alorithm_blue_bridge._模拟.递增序列;

/**
 * @Author congge
 * @Date 2023/9/17 21:48
 * @description 递增序列
 * https://www.lanqiao.cn/problems/819/learning/?page=1&first_category_id=1&sort=students_count
 */
public class Main {
    public static void main(String[] args) {
        String s = "VLPWJVVNNZSWFGHSFRBCOIJTPYNEURPIGKQGPSXUGNELGRVZAG\n" +
                "SDLLOVGRTWEYZKKXNKIRWGZWXWRHKXFASATDWZAPZRNHTNNGQF\n" +
                "ZGUGXVQDQAEAHOQEADMWWXFBXECKAVIGPTKTTQFWSWPKRPSMGA\n" +
                "BDGMGYHAOPPRRHKYZCMFZEDELCALTBSWNTAODXYVHQNDASUFRL\n" +
                "YVYWQZUTEPFSFXLTZBMBQETXGXFUEBHGMJKBPNIHMYOELYZIKH\n" +
                "ZYZHSLTCGNANNXTUJGBYKUOJMGOGRDPKEUGVHNZJZHDUNRERBU\n" +
                "XFPTZKTPVQPJEMBHNTUBSMIYEGXNWQSBZMHMDRZZMJPZQTCWLR\n" +
                "ZNXOKBITTPSHEXWHZXFLWEMPZTBVNKNYSHCIQRIKQHFRAYWOPG\n" +
                "MHJKFYYBQSDPOVJICWWGGCOZSBGLSOXOFDAADZYEOBKDDTMQPA\n" +
                "VIDPIGELBYMEVQLASLQRUKMXSEWGHRSFVXOMHSJWWXHIBCGVIF\n" +
                "GWRFRFLHAMYWYZOIQODBIHHRIIMWJWJGYPFAHZZWJKRGOISUJC\n" +
                "EKQKKPNEYCBWOQHTYFHHQZRLFNDOVXTWASSQWXKBIVTKTUIASK\n" +
                "PEKNJFIVBKOZUEPPHIWLUBFUDWPIDRJKAZVJKPBRHCRMGNMFWW\n" +
                "CGZAXHXPDELTACGUWBXWNNZNDQYYCIQRJCULIEBQBLLMJEUSZP\n" +
                "RWHHQMBIJWTQPUFNAESPZHAQARNIDUCRYQAZMNVRVZUJOZUDGS\n" +
                "PFGAYBDEECHUXFUZIKAXYDFWJNSAOPJYWUIEJSCORRBVQHCHMR\n" +
                "JNVIPVEMQSHCCAXMWEFSYIGFPIXNIDXOTXTNBCHSHUZGKXFECL\n" +
                "YZBAIIOTWLREPZISBGJLQDALKZUKEQMKLDIPXJEPENEIPWFDLP\n" +
                "HBQKWJFLSEXVILKYPNSWUZLDCRTAYUUPEITQJEITZRQMMAQNLN\n" +
                "DQDJGOWMBFKAIGWEAJOISPFPLULIWVVALLIIHBGEZLGRHRCKGF\n" +
                "LXYPCVPNUKSWCCGXEYTEBAWRLWDWNHHNNNWQNIIBUCGUJYMRYW\n" +
                "CZDKISKUSBPFHVGSAVJBDMNPSDKFRXVVPLVAQUGVUJEXSZFGFQ\n" +
                "IYIJGISUANRAXTGQLAVFMQTICKQAHLEBGHAVOVVPEXIMLFWIYI\n" +
                "ZIIFSOPCMAWCBPKWZBUQPQLGSNIBFADUUJJHPAIUVVNWNWKDZB\n" +
                "HGTEEIISFGIUEUOWXVTPJDVACYQYFQUCXOXOSSMXLZDQESHXKP\n" +
                "FEBZHJAGIFGXSMRDKGONGELOALLSYDVILRWAPXXBPOOSWZNEAS\n" +
                "VJGMAOFLGYIFLJTEKDNIWHJAABCASFMAKIENSYIZZSLRSUIPCJ\n" +
                "BMQGMPDRCPGWKTPLOTAINXZAAJWCPUJHPOUYWNWHZAKCDMZDSR\n" +
                "RRARTVHZYYCEDXJQNQAINQVDJCZCZLCQWQQIKUYMYMOVMNCBVY\n" +
                "ABTCRRUXVGYLZILFLOFYVWFFBZNFWDZOADRDCLIRFKBFBHMAXX";
//        String s = "LANN\n" +
//                "QIAO";
        String[] arrays = s.split("\n");
        int m = arrays.length;
        int n = arrays[0].length();
        char[][] map = new char[m][n];

        for (int i = 0; i < m; i++) {
            map[i] = arrays[i].toCharArray();
        }
        long ans = 0L;

        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                char preLetter = map[i][j];
                /**
                 * 同一行
                 */
                for (int k = j + 1; k < n; k++) {
                    if (preLetter < map[i][k]) {
                        ans++;
                        print(preLetter, map[i][k]);
                    }
                }
                /**
                 * 同一列
                 */
                for (int k = i + 1; k < m; k++) {
                    if (preLetter < map[k][j]) {
                        ans++;
                        print(preLetter, map[k][j]);
                    }
                }

                /**
                 * 同一45°右上上扬角
                 */
                int up = i - 1;
                int right = j + 1;
                while (up >= 0 && right < n) {
                    if (preLetter < map[up][right]) {
                        ans++;
                        print(preLetter, map[up][right]);
                    }
                    up--;
                    right++;
                }
                /**
                 * 同一45度右下扬角
                 */
                int down = i + 1;
                right = j + 1;
                while (down < m && right < n) {
                    if (preLetter < map[down][right]) {
                        ans++;
                        print(preLetter, map[down][right]);
                    }
                    down++;
                    right++;
                }
                /**
                 * 同一45度左上扬角
                 */
//                up = i - 1;
//                int left = j - 1;
//                while (up >= 0 && left >= 0) {
//                    if (preLetter < map[up][left]) {
//                        ans++;
//                        print(preLetter, map[up][left]);
//                    }
//                    up--;
//                    left--;
//                }

                /**
                 * 同一45度左下扬角
                 */
                down = i + 1;
                int left = j - 1;
                while (down < m && left >= 0) {
                    if (preLetter < map[down][left]) {
                        ans++;
                        print(preLetter, map[down][left]);
                    }
                    down++;
                    left--;
                }
            }
        }
        System.out.println(ans);
    }

    public static void print(char A, char B) {

    }
}
